STL stands for Standard Template Library. Standard not only because the library is a standard unto itself, but also because it has been incorporated into the draft ANSI C++ Standard. Template because the library is comprised entirely of C++ templates for container classes and generic algorithms. [Library, we hope, speaks for itself.] STL is the fruit of several years of research on generic programming by Alexander Stepanov and Meng Lee of Hewlett-Packard Laboratories and David Musser of Rensselaer Polytechnic Institute.
What is STL for?
To quote The Standard Template Library by Stepanov and Lee:
“The Standard Template Library provides a set of well
structured generic C++ components that work together in a
seamless way. Special care has been taken to ensure that
all the template algorithms work not only on the data
structures in the library, but also on built-in C++ data
structures. For example, all the algorithms work on regular
pointers. The orthogonal design of the library allows
programmers to use library data structures with their own
algorithms, and to use library algorithms with their own
data structures. The well specified semantic and complexity
requirements guarantee that a user component will work with
the library, and that it will work efficiently. This
flexibility ensures the widespread utility of the library.”
Where can I find out more about STL?
The Standard Template Library is included on this CD in DocViewer format. It is a complete description of the library, although a very formal one without much in the way of rationale or examples. Another excellent source of information on STL can be found on the World Wide Web. Its URL is:
http://www.cs.rpi.edu/~musser/stl.html
and it provides a wealth of material, including the STL Online Algorithm Reference, which is a collection of hypermedia “data sheets” describing all of STL’s generic algorithms. Examples are provided with source code. You can even run the examples online, as well as some additional animated examples, provided that you have MacX or other X-Window server software available.
How do I use STL?
STL, being comprised solely of template declarations, resides completely in a set of header files:
algo.h - includes all the algorithms
algobase.h - auxiliary file
bool.h - simulates bool
bvector.h - bit_vector
defalloc.h - allocator
deque.h - deque
function.h - operators, function objects and function adaptors
heap.h - auxiliary file
iterator.h - iterator tags, stream iterators and iterator adaptors
list.h - list
map.h - map
multimap.h - multimap
multiset.h - multiset
pair.h - pair
projectn.h - auxiliary file
random.cpp - random number generator. It should be compiled and linked
if random_shuffle is used.
set.h - set
stack.h - container adaptors
tempbuf.cpp - an auxiliary buffer for get_temporary_buffer;
it should be compiled and linked if get_temporary_buffer,
stable_partition, inplace_merge or stable_sort are used.
tempbuf.h - get_temporary_buffer
tree.h - auxiliary file
vector.h - vector
#include those header files you require or you can just #include <stl.h> to include everything. A precompiled header <STL> is also provided, but if you need to use MacHeaders or any other precompiled header as well, you’ll need to build a custom precompiled header that incorporates them together. You can use the STL project used to build the STL precompiled header as a guide.
Note that the header <bvector.h> cannot be precompiled with the current compiler because it contains a static data declaration. Also, if you are using <iterator.h> be sure to #include <iostreams.h> before you instantiate any iostream iterators. <iostreams.h> is not #included by <iterator.h> because <iostreams.h> also declares static data and #including it would preclude the possibility of incorporating <iterator.h> into any precompiled headers.
There are no “libraries” (in the linkable sense) that need to be added to your project. However, some portions of STL make use of elements of the ANSI and ANSI++ libraries.